<?php
class ReportHandler{
private $con;

public function setCon($conn){
$this->con=$conn;
}

//Used to get income of invidual subject of specific class 
public function getIndividualReport($subgr,$year,$month){

$sql="select subject_code.subject,
			 payment.p_fee,
			 subject_code.grade,
			 sum(payment.p_fee) 
as income,count(payment.p_fee) 
as numb from payment,subject_code 
where payment.sub_gr=subject_code.sub_gr and 
	  year(payment.paid_date)='$year' and 
	  month(payment.paid_date)='$month' and 
	  payment.sub_gr='$subgr'";

$result=mysql_query($sql,$this->con) or die(mysql_error());
return $result;
}



//Used to get income collection  of whole classes  
public function getwholeReport($year,$month){


$sql="select subject_code.subject,
subject_code.grade,
sum(payment.p_fee) 
as income from payment,subject_code 
where payment.sub_gr=subject_code.sub_gr and 
year(payment.paid_date)='$year' and 
month(payment.paid_date)='$month' 
group by payment.sub_gr";

$result=mysql_query($sql,$this->con) or die(mysql_error());

return $result;
}

//Used to get income collection  of a lecture  
public function getEmpIncomeReport($empno,$year,$month){


$sql="select subject_code.subject,
subject_code.grade,
sum(payment.p_fee) as income from 
payment,subject_code,class_sched 
where class_sched.emp_no='$empno' and class_sched.sub_gr=subject_code.sub_gr and class_sched.sub_gr=payment.sub_gr and month(payment.paid_date)='$month' and year(payment.paid_date)='$year' and   
payment.sub_gr=subject_code.sub_gr 
group by payment.sub_gr";

$result=mysql_query($sql,$this->con) or die(mysql_error());

return $result;
}




public function getAttstudReport($regno,$month){

$sql="select subject_code.subject,subject_code.grade,year(stud_attend.attend_date) as years,count(stud_attend.attend_date) as att from stud_attend,subject_code where stud_attend.sub_gr=subject_code.sub_gr and reg_no='$regno' and month(stud_attend.attend_date)='$month' group by stud_attend.sub_gr";

$result=mysql_query($sql,$this->con) or die(mysql_error());

return $result;
}

public function getAttempReport($empno,$month){

$sql="select employee_attend.attend_date,employee_attend.inn,employee_attend.outt from employee_attend where employee_attend.emp_no='$empno' and month(employee_attend.attend_date)='$month'";

$result=mysql_query($sql,$this->con) or die(mysql_error());

return $result;
}




//Used to get income collection of each grade of whole classes 

public function getGradeIncomeMonthly($grade,$year,$month){

$sql="select subject_code.subject,
sum(payment.p_fee) as income,
count(payment.p_fee) as numb 
from payment,subject_code 
where payment.sub_gr=subject_code.sub_gr and 
year(payment.paid_date)='$year' and 
month(payment.paid_date)='$month' and 
subject_code.grade='$grade'
group by subject_code.subject"; 

$result=mysql_query($sql,$this->con) or die(mysql_error());

return $result;


}


//used to get income of each grade based on month in specific year

public function getAnnualGrade($grade,$year){

$sql="select month(payment.paid_date) as months,
sum(payment.p_fee) as income 
from payment,subject_code 
where payment.sub_gr=subject_code.sub_gr and 
year(payment.paid_date)='$year' and 
subject_code.grade='$grade' 
group by month(payment.paid_date) 
order by sum(payment.p_fee) desc";

$result=mysql_query($sql,$this->con) or die(mysql_error());

return $result;


}



public function getGradeSchedule($grade){


$sql="Select class_sched.schedule_id,class_sched.days,class_sched.start,class_sched.end,subject_code.subject,subject_code.c_fee from class_sched,subject_code where class_sched.sub_gr=subject_code.sub_gr and subject_code.grade='$grade'";

$result=mysql_query($sql,$this->con) or die(mysql_error());

return $result;


}


}



?>